//
//  ParaObject.m
//  iStock Global
//
//  Created by Andy on 2010/10/24.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "DBHelper.h"
#import "ParaObject.h"
#import "CorePlot-CocoaTouch.h" 
@implementation ParaObject

@synthesize CaArray_MovingAverage;
@synthesize CaArray_LF;
@synthesize CaArray_MESA;
@synthesize CaArray_xMESA;
@synthesize CaArray_KD;
@synthesize CaArray_volume;

-(NSMutableDictionary *)getSqlPara:(NSString *)aSymbol tradesystemname:(NSString *)tradesystemname sortselect:(NSString *)asortselect dwn:(NSString *)cdwm {	
	
    NSMutableDictionary *outpara;
	
    outpara=[[[NSMutableDictionary alloc] init] autorelease];
    
	const char *sql = NULL;	
	NSString *tsql;	
	
	
	//啓動資料庫檔案============
	//DBHelper *helper =[DBHelper newInstance:@"data1" andEXT:@"sqlite3" andfullname:@"data1.sqlite3"];
	NSString *ver;
	ver=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
	ver=[ver stringByReplacingOccurrencesOfString:@"." withString:@"_"];
	NSString *filename;
	filename=@"data_";
	filename=[filename stringByAppendingString:ver];
	NSString *filenamexx;
	filenamexx=@"sqlite3";
	NSString *fullfilename;
	fullfilename=[filename stringByAppendingString:@"."];
	fullfilename=[fullfilename stringByAppendingString:filenamexx];
	DBHelper *helper =[DBHelper newInstance:filename andEXT:filenamexx andfullname:fullfilename];		
	sqlite3 *database = [helper openDatabase]; 
	
    sqlite3_stmt *stm=nil;
	//=========================
		
	
	if ([tradesystemname isEqualToString:@"MESA"]) {
		float  FastLim=0;
        float  SlowLim=0;
        // 注意要修改 FastLim,SlowLim		
		tsql=@"SELECT id,code,FastLim,SlowLim FROM ";
		tsql=[tsql stringByAppendingString:tradesystemname];
		tsql=[tsql stringByAppendingString:@"_"];
		tsql=[tsql stringByAppendingString:asortselect];
		tsql=[tsql stringByAppendingString:@"_"];
		tsql=[tsql stringByAppendingString:cdwm];
		tsql=[tsql stringByAppendingString:@" where code='"];
		tsql=[tsql stringByAppendingString:aSymbol];
		tsql=[tsql stringByAppendingString:@"'"];
		sql=[tsql UTF8String];		
		if(sqlite3_prepare_v2(database, sql, strlen(sql), &stm, NULL)== SQLITE_OK) {
			BOOL havedata;
			havedata=NO;
			
			
			while(sqlite3_step(stm) ==SQLITE_ROW)
			{
				 
				char *field2=(char *)sqlite3_column_text(stm, 2);
				NSString *ss2=[[NSString alloc]initWithUTF8String:field2];				
				char *field3=(char *)sqlite3_column_text(stm, 3);
				NSString *ss3=[[NSString alloc]initWithUTF8String:field3];				
				
				 FastLim=[ss2 floatValue];
				 SlowLim=[ss3 floatValue];
                [ss2 release];
                [ss3 release];
                
				//NSLog(@"cc0可以找到資料=%@  %0.03f  %0.03f %@",ss1, FastLim , SlowLim ,cdwm);
				
				havedata=YES;
			}
			if (havedata==YES) {
				//NSLog(@"aaaa0有資料");
				
			}
			else {
				if ([asortselect isEqualToString: @"0"]) {
					FastLim=0.3;
					SlowLim=0.03;		
				}
				if ([asortselect isEqualToString: @"1"]) {
					FastLim=0.25;
					SlowLim=0.025;		
				}
				if ([asortselect isEqualToString: @"2"]) {
					FastLim=0.2;
					SlowLim=0.02;		
				}				
			}
			
			
			
			
		}
		
	 	
		
		[outpara setObject:[NSString stringWithFormat:@"%f",FastLim] forKey:@"FastLim"];
		[outpara setObject:[NSString stringWithFormat:@"%f",SlowLim] forKey:@"SlowLim"];
		
		
		
	}
	else if([tradesystemname isEqualToString:@"LF"]) {
		
		float  Bratio=0;
        float  Sratio=0 ;
		int BRangeDay=0;
        int SRangeDay=0;
        // 注意要修改 FastLim,SlowLim		
		tsql=@"SELECT id,code,BRangeDay,SRangeDay,Bratio,Sratio FROM ";
		tsql=[tsql stringByAppendingString:tradesystemname];
		tsql=[tsql stringByAppendingString:@"_"];
		tsql=[tsql stringByAppendingString:asortselect];
		tsql=[tsql stringByAppendingString:@"_"];
		tsql=[tsql stringByAppendingString:cdwm];
		tsql=[tsql stringByAppendingString:@" where code='"];
		tsql=[tsql stringByAppendingString:aSymbol];
		tsql=[tsql stringByAppendingString:@"'"];
		sql=[tsql UTF8String];		
		if(sqlite3_prepare_v2(database, sql, strlen(sql), &stm, NULL)== SQLITE_OK) {
			BOOL havedata;
			havedata=NO;
			
			
			while(sqlite3_step(stm) ==SQLITE_ROW)
			{
				
				char *field2=(char *)sqlite3_column_text(stm, 2);
				NSString *ss2=[[NSString alloc]initWithUTF8String:field2];				
				char *field3=(char *)sqlite3_column_text(stm, 3);
				NSString *ss3=[[NSString alloc]initWithUTF8String:field3];				
				
				char *field4=(char *)sqlite3_column_text(stm, 4);
				NSString *ss4=[[NSString alloc]initWithUTF8String:field4];				
				char *field5=(char *)sqlite3_column_text(stm, 5);
				NSString *ss5=[[NSString alloc]initWithUTF8String:field5];					
				
				BRangeDay=[ss2 floatValue];
				SRangeDay=[ss3 floatValue];
				Bratio=[ss4 floatValue];
				Sratio=[ss5 floatValue];				
				
                
				//NSLog(@"cc0可以找到資料=%@  %0.03f  %0.03f %@",ss1, FastLim , SlowLim ,cdwm);
				[ss2 release];
                [ss3 release];
                [ss4 release];
                [ss5 release];
                
				havedata=YES;
			}
			if (havedata==YES) {
			NSLog(@"aaaa0有資料");
				
			}
			else {
				if ([asortselect isEqualToString: @"0"]) {
					BRangeDay=20;
					SRangeDay=20;
					Bratio=0.3;
					Sratio=0.3;	
					
					 					
				}
				if ([asortselect isEqualToString: @"1"]) {
					BRangeDay=15;
					SRangeDay=15;
					Bratio=0.2;
					Sratio=0.2;	
					 						
				}
				if ([asortselect isEqualToString: @"2"]) {
					BRangeDay=10;
					SRangeDay=10;
					Bratio=0.15;
					Sratio=0.15;	
					 				
				}
							
			}
			
			
			
			
		}
		
	 	[outpara setObject:[NSString stringWithFormat:@"%f",Bratio] forKey:@"Bratio"];
		[outpara setObject:[NSString stringWithFormat:@"%f",Sratio] forKey:@"Sratio"];
		[outpara setObject:[NSString stringWithFormat:@"%i",BRangeDay] forKey:@"BRangeDay"];
		[outpara setObject:[NSString stringWithFormat:@"%i",SRangeDay] forKey:@"SRangeDay"];
		
		
	}
	
	
	
	 
	
	//結束查詢作業
	sqlite3_finalize(stm);		
	 
	
	return outpara	;
	

}

-(id)initWithTargetSymbol:(NSString *)aSymbol dwm:(NSString *)adwm{
	self=[super init];
    if (self) {
		
		//NSNumber *yesBool=[NSNumber numberWithBool:YES];
		NSNumber *noBool=[NSNumber numberWithBool:NO];		
	 	
		//!!!!增加策略策略要修改地方 上
		float MESA_0_FastLim,MESA_0_SlowLim;
        NSMutableDictionary *MESA_0;
		MESA_0=[self getSqlPara:aSymbol tradesystemname:@"MESA" sortselect:@"0" dwn:adwm];
		MESA_0_FastLim =[[MESA_0 objectForKey:@"FastLim"] floatValue];
		MESA_0_SlowLim =[[MESA_0 objectForKey:@"SlowLim"] floatValue];
		//[MESA_0 release];
		 MESA_0=nil;
		
		float MESA_1_FastLim,MESA_1_SlowLim;
		NSMutableDictionary *MESA_1;
		MESA_1=[self getSqlPara:aSymbol tradesystemname:@"MESA" sortselect:@"1" dwn:adwm];
		MESA_1_FastLim =[[MESA_1 objectForKey:@"FastLim"] floatValue];
		MESA_1_SlowLim =[[MESA_1 objectForKey:@"SlowLim"] floatValue];
		//[MESA_1 release];
		MESA_1=nil;		
		
		
		float MESA_2_FastLim,MESA_2_SlowLim;
		NSMutableDictionary *MESA_2;
		MESA_2=[self getSqlPara:aSymbol tradesystemname:@"MESA" sortselect:@"2" dwn:adwm];
		MESA_2_FastLim =[[MESA_2 objectForKey:@"FastLim"] floatValue];
		MESA_2_SlowLim =[[MESA_2 objectForKey:@"SlowLim"] floatValue];		
		//[MESA_2 release];
		MESA_2=nil;
		
		int LF_0_BRangeDay,LF_0_SRangeDay;
		float LF_0_Bratio,LF_0_Sratio;
		NSMutableDictionary *LF_0;
		LF_0=[self getSqlPara:aSymbol tradesystemname:@"LF" sortselect:@"0" dwn:adwm];
		LF_0_Bratio =[[LF_0 objectForKey:@"Bratio"] floatValue];
		LF_0_Sratio =[[LF_0 objectForKey:@"Sratio"] floatValue];
		LF_0_BRangeDay =[[LF_0 objectForKey:@"BRangeDay"] intValue];
		LF_0_SRangeDay =[[LF_0 objectForKey:@"SRangeDay"] intValue];
		//[LF_0 release];
		LF_0=nil;		
		
		int LF_1_BRangeDay,LF_1_SRangeDay;
		float LF_1_Bratio,LF_1_Sratio;
		NSMutableDictionary *LF_1;
		LF_1=[self getSqlPara:aSymbol tradesystemname:@"LF" sortselect:@"1" dwn:adwm];
		LF_1_Bratio =[[LF_1 objectForKey:@"Bratio"] floatValue];
		LF_1_Sratio =[[LF_1 objectForKey:@"Sratio"] floatValue];
		LF_1_BRangeDay =[[LF_1 objectForKey:@"BRangeDay"] intValue];
		LF_1_SRangeDay =[[LF_1 objectForKey:@"SRangeDay"] intValue];
		//[LF_1 release];
		LF_1=nil;				
		
		
		
		int LF_2_BRangeDay,LF_2_SRangeDay;
		float LF_2_Bratio,LF_2_Sratio;
		NSMutableDictionary *LF_2;
		LF_2=[self getSqlPara:aSymbol tradesystemname:@"LF" sortselect:@"2" dwn:adwm];
		LF_2_Bratio =[[LF_2 objectForKey:@"Bratio"] floatValue];
		LF_2_Sratio =[[LF_2 objectForKey:@"Sratio"] floatValue];
		LF_2_BRangeDay =[[LF_2 objectForKey:@"BRangeDay"] intValue];
		LF_2_SRangeDay =[[LF_2 objectForKey:@"SRangeDay"] intValue];
		//[LF_2 release];
		LF_2=nil;			
		
	
		
		
		//!!!!增加策略策略要修改地方 下	
		NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];		
		
		//移動均線
	    CaArray_MovingAverage=[[NSMutableArray alloc] init];
		
		NSMutableDictionary *singleMovingArray;
		
		singleMovingArray=[[NSMutableDictionary alloc] init];
		[singleMovingArray setValue:@"Caverage1"  forKey:@"idendfiler"];
		[singleMovingArray setValue:[prefs objectForKey: @"isMVindicator1"]  forKey:@"isShow"];
		[singleMovingArray setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_MVindicator1"] intValue]]  forKey:@"movingday"];
		[singleMovingArray setValue:[CPTColor redColor] forKey:@"linecolor"];
		[singleMovingArray setValue:@"2.0" forKey:@"linewith"];
		[CaArray_MovingAverage addObject:singleMovingArray];
		[singleMovingArray release];
        
		singleMovingArray=[[NSMutableDictionary alloc] init];
		[singleMovingArray setValue:@"Caverage2"  forKey:@"idendfiler"];
		[singleMovingArray setValue:[prefs objectForKey: @"isMVindicator2"] forKey:@"isShow"];
		[singleMovingArray setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_MVindicator2"] intValue]]  forKey:@"movingday"];	
		[singleMovingArray setValue:[CPTColor lightGrayColor] forKey:@"linecolor"];		
		[singleMovingArray setValue:@"2.0" forKey:@"linewith"];		
		[CaArray_MovingAverage addObject:singleMovingArray];
		[singleMovingArray release];        
        
		singleMovingArray=[[NSMutableDictionary alloc] init];
		[singleMovingArray setValue:@"Caverage3"  forKey:@"idendfiler"];
		[singleMovingArray setValue:[prefs objectForKey: @"isMVindicator3"] forKey:@"isShow"];
		[singleMovingArray setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_MVindicator3"] intValue]]  forKey:@"movingday"];	
		[singleMovingArray setValue:[CPTColor blueColor] forKey:@"linecolor"];		
		[singleMovingArray setValue:@"2.0" forKey:@"linewith"];		
		[CaArray_MovingAverage addObject:singleMovingArray];
		[singleMovingArray release];        
        
		singleMovingArray=[[NSMutableDictionary alloc] init];
		[singleMovingArray setValue:@"Caverage4"  forKey:@"idendfiler"];
		[singleMovingArray setValue:[prefs objectForKey: @"isMVindicator4"] forKey:@"isShow"];
		[singleMovingArray setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_MVindicator4"] intValue]]  forKey:@"movingday"];	
		[singleMovingArray setValue:[CPTColor greenColor] forKey:@"linecolor"];		
		[singleMovingArray setValue:@"2.0" forKey:@"linewith"];		
		[CaArray_MovingAverage addObject:singleMovingArray];
		[singleMovingArray release];        
        
		singleMovingArray=[[NSMutableDictionary alloc] init];
		[singleMovingArray setValue:@"Caverage5"  forKey:@"idendfiler"];
		[singleMovingArray setValue:[prefs objectForKey: @"isMVindicator5"] forKey:@"isShow"];
		[singleMovingArray setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_MVindicator5"] intValue]] forKey:@"movingday"];	
		[singleMovingArray setValue:[CPTColor orangeColor] forKey:@"linecolor"];		
		[singleMovingArray setValue:@"2.0" forKey:@"linewith"];		
		[CaArray_MovingAverage addObject:singleMovingArray];		
		[singleMovingArray release];        
        /*
		singleMovingArray=[[NSMutableDictionary alloc] init];
		[singleMovingArray setValue:@"Caverage6"  forKey:@"idendfiler"];
		[singleMovingArray setValue:noBool forKey:@"isShow"];
		[singleMovingArray setValue: @"90"  forKey:@"movingday"];	
		[singleMovingArray setValue:[CPColor blueColor] forKey:@"linecolor"];		
		[singleMovingArray setValue:@"1.0" forKey:@"linewith"];		
		[CaArray_MovingAverage addObject:singleMovingArray];
		*/
		
		//LF 笑傲曲線
		
		CaArray_LF=[[NSMutableArray alloc] init];
		
		NSMutableDictionary *singleLF;
		
		singleLF=[[NSMutableDictionary alloc] init];
		[singleLF setValue:@"LF1"  forKey:@"idendfiler"];
		[singleLF setValue:[prefs objectForKey: @"isLF1"] forKey:@"isShow"];
		[singleLF setValue: [NSString stringWithFormat:@"%i",LF_0_BRangeDay ]  forKey:@"BRangeDay"];
		[singleLF setValue: [NSString stringWithFormat:@"%i",LF_0_SRangeDay ]  forKey:@"SRangeDay"];		 
		[singleLF setValue: [NSString stringWithFormat:@"%0.03f",LF_0_Bratio ]  forKey:@"Bratio"];
		[singleLF setValue: [NSString stringWithFormat:@"%0.03f",LF_0_Sratio ]  forKey:@"Sratio"];		 
		[singleLF setValue:[CPTColor yellowColor] forKey:@"Blinecolor"];
		[singleLF setValue:@"2.0" forKey:@"Blinewith"];
		[singleLF setValue:[CPTColor magentaColor] forKey:@"Slinecolor"];
		[singleLF setValue:@"2.0" forKey:@"Slinewith"];		
		[CaArray_LF addObject:singleLF];
		[singleLF release];
        
    	singleLF=[[NSMutableDictionary alloc] init];
		[singleLF setValue:@"LF2"  forKey:@"idendfiler"];
		[singleLF setValue:[prefs objectForKey: @"isLF2"] forKey:@"isShow"];
		[singleLF setValue: [NSString stringWithFormat:@"%i",LF_1_BRangeDay ]  forKey:@"BRangeDay"];
		[singleLF setValue: [NSString stringWithFormat:@"%i",LF_1_SRangeDay ]  forKey:@"SRangeDay"];		 
		[singleLF setValue: [NSString stringWithFormat:@"%0.03f",LF_1_Bratio ]  forKey:@"Bratio"];
		[singleLF setValue: [NSString stringWithFormat:@"%0.03f",LF_1_Sratio ]  forKey:@"Sratio"];		 	 
		[singleLF setValue:[CPTColor redColor] forKey:@"Blinecolor"];
		[singleLF setValue:@"2.0" forKey:@"Blinewith"];
		[singleLF setValue:[CPTColor greenColor] forKey:@"Slinecolor"];
		[singleLF setValue:@"2.0" forKey:@"Slinewith"];		
		[CaArray_LF addObject:singleLF];	
		[singleLF release];        
        
		singleLF=[[NSMutableDictionary alloc] init];
		[singleLF setValue:@"LF3"  forKey:@"idendfiler"];
		[singleLF setValue:[prefs objectForKey: @"isLF3"] forKey:@"isShow"];
		[singleLF setValue: [NSString stringWithFormat:@"%i",LF_2_BRangeDay ]  forKey:@"BRangeDay"];
		[singleLF setValue: [NSString stringWithFormat:@"%i",LF_2_SRangeDay ]  forKey:@"SRangeDay"];		 
		[singleLF setValue: [NSString stringWithFormat:@"%0.03f",LF_2_Bratio ]  forKey:@"Bratio"];
		[singleLF setValue: [NSString stringWithFormat:@"%0.03f",LF_2_Sratio ]  forKey:@"Sratio"];		 		 
		[singleLF setValue:[CPTColor whiteColor] forKey:@"Blinecolor"];
		[singleLF setValue:@"1.0" forKey:@"Blinewith"];
		[singleLF setValue:[CPTColor orangeColor] forKey:@"Slinecolor"];
		[singleLF setValue:@"1.0" forKey:@"Slinewith"];		
		[CaArray_LF addObject:singleLF];
		[singleLF release];         
        
		//MESA 採用NSMutableArray  		 
		CaArray_MESA=[[NSMutableArray alloc] init];
		
		NSMutableDictionary *singleMESA;
		
		singleMESA=[[NSMutableDictionary alloc] init];
		[singleMESA setValue:@"Cmesa1_"  forKey:@"idendfiler"];
		[singleMESA setValue:[prefs objectForKey: @"isMESA1"] forKey:@"isShow"];
		[singleMESA setValue: [NSString stringWithFormat:@"%0.03f",MESA_0_FastLim]  forKey:@"FastLim"];
		[singleMESA setValue: [NSString stringWithFormat:@"%0.03f",MESA_0_SlowLim]  forKey:@"SlowLim"];		 
        
        //標記:Bloomberg 橘色        
        [singleMESA setValue: [CPTColor colorWithComponentRed:252.0/255.0 green:157.0/255.0 blue:15.0/255.0 alpha:1.0 ] forKey:@"FAMAlinecolor"];
        
		[singleMESA setValue:@"1.5" forKey:@"FAMAlinewith"];
		[singleMESA setValue:[CPTColor whiteColor] forKey:@"MAMAlinecolor"];
		[singleMESA setValue:@"1.5" forKey:@"MAMAlinewith"];		
		[CaArray_MESA addObject:singleMESA];	
		[singleMESA release];
        
		singleMESA=[[NSMutableDictionary alloc] init];
		[singleMESA setValue:@"Cmesa2_"  forKey:@"idendfiler"];
		[singleMESA setValue:[prefs objectForKey: @"isMESA2"] forKey:@"isShow"];
		[singleMESA setValue: [NSString stringWithFormat:@"%0.03f",MESA_1_FastLim]  forKey:@"FastLim"];
		[singleMESA setValue: [NSString stringWithFormat:@"%0.03f",MESA_1_SlowLim]  forKey:@"SlowLim"];		
		//標記:Bloomberg 橘色        
        [singleMESA setValue:[CPTColor colorWithComponentRed:252.0/255.0 green:157.0/255.0 blue:15.0/255.0 alpha:1.0 ] forKey:@"FAMAlinecolor"];
		[singleMESA setValue:@"2.5" forKey:@"FAMAlinewith"];
		[singleMESA setValue:[CPTColor whiteColor] forKey:@"MAMAlinecolor"];
		[singleMESA setValue:@"2.5" forKey:@"MAMAlinewith"];		
		[CaArray_MESA addObject:singleMESA];
		[singleMESA release];        
        
		singleMESA=[[NSMutableDictionary alloc] init];
		[singleMESA setValue:@"Cmesa3_"  forKey:@"idendfiler"];
		[singleMESA setValue:[prefs objectForKey: @"isMESA3"] forKey:@"isShow"];
		[singleMESA setValue: [NSString stringWithFormat:@"%0.03f",MESA_2_FastLim]  forKey:@"FastLim"];
		[singleMESA setValue: [NSString stringWithFormat:@"%0.03f",MESA_2_SlowLim]  forKey:@"SlowLim"];	
		//標記:Bloomberg 橘色        
        [singleMESA setValue:[CPTColor colorWithComponentRed:252.0/255.0 green:157.0/255.0 blue:15.0/255.0 alpha:1.0 ] forKey:@"FAMAlinecolor"];
		[singleMESA setValue:@"3.5" forKey:@"FAMAlinewith"];
		[singleMESA setValue:[CPTColor whiteColor] forKey:@"MAMAlinecolor"];
		[singleMESA setValue:@"3.5" forKey:@"MAMAlinewith"];		
		[CaArray_MESA addObject:singleMESA];	
		[singleMESA release];        
        
		//xMESA 利用Ｃ＋＋的陣列來計算 目前僅最大極限是兩組
		
		CaArray_xMESA=[[NSMutableArray alloc] init];
		
		NSMutableDictionary *xsingleMESA;
		
		xsingleMESA=[[NSMutableDictionary alloc] init];
		[xsingleMESA setValue:@"xCmesa1_"  forKey:@"idendfiler"];
		[xsingleMESA setValue:noBool forKey:@"isShow"];
		[xsingleMESA setValue: @"0.25"  forKey:@"FastLim"];
		[xsingleMESA setValue: @"0.01"  forKey:@"SlowLim"];		 
		[xsingleMESA setValue:[CPTColor whiteColor] forKey:@"FAMAlinecolor"];
		[xsingleMESA setValue:@"3.0" forKey:@"FAMAlinewith"];
		[xsingleMESA setValue:[CPTColor blueColor] forKey:@"MAMAlinecolor"];
		[xsingleMESA setValue:@"3.0" forKey:@"MAMAlinewith"];		
		[CaArray_xMESA addObject:xsingleMESA];	
		[xsingleMESA release];
        
        
		xsingleMESA=[[NSMutableDictionary alloc] init];
		[xsingleMESA setValue:@"xCmesa2_"  forKey:@"idendfiler"];
		[xsingleMESA setValue:noBool forKey:@"isShow"];
		[xsingleMESA setValue: @"0.3"  forKey:@"FastLim"];
		[xsingleMESA setValue: @"0.03"  forKey:@"SlowLim"];		 
		[xsingleMESA setValue:[CPTColor greenColor] forKey:@"FAMAlinecolor"];
		[xsingleMESA setValue:@"1.0" forKey:@"FAMAlinewith"];
		[xsingleMESA setValue:[CPTColor redColor] forKey:@"MAMAlinecolor"];
		[xsingleMESA setValue:@"1.0" forKey:@"MAMAlinewith"];		
		[CaArray_xMESA addObject:xsingleMESA];
		[xsingleMESA release];        
        
		//KD 利用Ｃ＋＋的陣列來計算 目前僅最大極限是1組
		
		CaArray_KD=[[NSMutableArray alloc] init];
		
		NSMutableDictionary *singleKD;
		
		singleKD=[[NSMutableDictionary alloc] init];
		[singleKD setValue:@"KD"  forKey:@"idendfiler"];
		[singleKD setValue:[prefs objectForKey: @"isKDindicator"] forKey:@"isShow"];
		[singleKD setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_KD_N"] intValue]]   forKey:@"N"];
		[singleKD setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_KD_M1"] intValue]]   forKey:@"M1"];
		[singleKD setValue: [NSString stringWithFormat:@"%i",[[prefs objectForKey: @"number_KD_M2"] intValue]]   forKey:@"M2"];
		[singleKD setValue:[CPTColor whiteColor] forKey:@"Klinecolor"];
		[singleKD setValue:@"1.0" forKey:@"Klinewith"];
		[singleKD setValue:[CPTColor redColor] forKey:@"Dlinecolor"];
		[singleKD setValue:@"1.0" forKey:@"Dlinewith"];		
		
		[CaArray_KD addObject:singleKD];
		[singleKD release];
		//volume 目前僅最大極限是1組
		
		CaArray_volume=[[NSMutableArray alloc] init];
		
		NSMutableDictionary *singlevolume;
		
		singlevolume=[[NSMutableDictionary alloc] init];
		[singlevolume setValue:@"Volume Plot"  forKey:@"idendfiler"];
		[singlevolume setValue:[prefs objectForKey: @"isVolumeindicator"] forKey:@"isShow"];
	    [singlevolume setValue:[CPTColor whiteColor] forKey:@"lineColor"];
		[singlevolume setValue:@"2.5" forKey:@"barWidth"];
		
		
		[CaArray_volume addObject:singlevolume];			
		[singlevolume release];
		
	}
	return self;
}

 

-(void)dealloc {
    NSLog(@"ParaObject-dealloc");
	//移動均線參數值
	[CaArray_MovingAverage release];
	CaArray_MovingAverage=nil;
	//笑傲曲線參數值
	[CaArray_LF release];
	CaArray_LF=nil;
	//MESA
	[CaArray_MESA release];
	CaArray_MESA=nil;
	
	//xMESA
	[CaArray_xMESA release];
	CaArray_xMESA=nil;
	//KD
	[CaArray_KD release];
	CaArray_KD=nil;
	//volume
	[CaArray_volume release];
	CaArray_volume=nil;
	
	
	[super dealloc];
}


@end
